package com.qf.service.impl;

import com.qf.mapper.DeptMapper;
import com.qf.pojo.Dept;
import com.qf.service.DeptService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Resource
    private DeptMapper deptMapper;
    @Override
    public List<Dept> findAll () {
        return deptMapper.findAll();
    }

    @Override
    public boolean delete (int id) {
        int i = deptMapper.deleteById(id);
        if (i>-1)return true;
        return false;
    }

    @Override
    public Dept findOne (int id) {
        return deptMapper.findOne(id);
    }

    @Override
    public boolean update (Dept dept) {
        int i = deptMapper.update (dept);
        if (i>-1) {
            return true;
        }
        return false;
    }

    @Override
    public Dept addDept (Dept dept) {

        try {
            int i = deptMapper.addDept (dept);
            if (i>-1)return dept;
        } catch (Exception e) {
            e.printStackTrace ();
        }
        return null;
    }
}
